<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>箭头函数</title>
	</head>
	<body>
		<script type="text/javascript">
			//1,箭头函数不能做构造函数
			// let Person = () =>{
			// 	console.log(1);
			// } 
			// let person  = new Person()//Person is not a constructor
			//2箭头函数不建议做对象
			//this指向不正确
			let obj  = 
			{
				 "name":"枫叶",
				 "age":21,
				 fun:()=>{
					 console.log(this);
				 }
			}
			obj.fun()
			
			function a() {
				return{
					"name": "枫叶",
					"age": 21,
					fun: () => {
						console.log(this);
					}
				}
			
			}
			console.log(a()) //此时指向当前对象,因为箭头函数指向的是上一层环境对象  一个{}表示一个环境(也是就是作用域)
		</script>
	</body>
</html>
